package com.haiyuancloud.create.properties.service.impl;

import com.haiyuancloud.create.properties.impl.*;
import com.haiyuancloud.base.deal.core.chain.compile.model.HyDealDBModel;
import com.haiyuancloud.create.properties.service.HyDealDBService;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Log4j
@Service("com.haiyuancloud.create.properties.impl.HyDealDBServiceImpl")
public class HyDealDBServiceImpl implements HyDealDBService {

    @Resource
    private DealDataSourceProperties dealDataSourceProperties;

    @Resource
    private LogDataSourceProperties logDataSourceProperties;

    @Resource
    private MasterDataSourceProperties masterDataSourceProperties;

    @Resource
    private MetaDataSourceProperties metaDataSourceProperties;

    @Resource
    private OrgDataSourceProperties orgDataSourceProperties;

    @Resource
    private PrdDataSourceProperties prdDataSourceProperties;

    @Resource
    private StatDataSourceProperties statDataSourceProperties;

    @Resource
    private UiDataSourceProperties uiDataSourceProperties;

    @Override
    public Map<String, HyDealDBModel> initHyDealDBCache() {
        Map<String, HyDealDBModel> cache = new HashMap<>();
        HyDealDBModel hyUiDealDBModel = uiDataSourceProperties.getHyDealDBModel();
        cache.put(hyUiDealDBModel.getDataSource(),hyUiDealDBModel);

        HyDealDBModel hyStatDealDBModel = statDataSourceProperties.getHyDealDBModel();
        cache.put(hyStatDealDBModel.getDataSource(),hyStatDealDBModel);

        HyDealDBModel hyDealDealDBModel = dealDataSourceProperties.getHyDealDBModel();
        cache.put(hyDealDealDBModel.getDataSource(),hyDealDealDBModel);


        HyDealDBModel hyLogDealDBModel = logDataSourceProperties.getHyDealDBModel();
        cache.put(hyLogDealDBModel.getDataSource(),hyLogDealDBModel);

        HyDealDBModel hyMasterDealDBModel = masterDataSourceProperties.getHyDealDBModel();
        cache.put(hyMasterDealDBModel.getDataSource(),hyMasterDealDBModel);

        HyDealDBModel hyMetaDealDBModel = metaDataSourceProperties.getHyDealDBModel();
        cache.put(hyMetaDealDBModel.getDataSource(),hyMetaDealDBModel);

        HyDealDBModel hyOrgDealDBModel = orgDataSourceProperties.getHyDealDBModel();
        cache.put(hyOrgDealDBModel.getDataSource(),hyOrgDealDBModel);


        HyDealDBModel hyPrdDealDBModel = prdDataSourceProperties.getHyDealDBModel();
        cache.put(hyPrdDealDBModel.getDataSource(),hyPrdDealDBModel);
        return cache;
    }
}
